/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 10:34:50 AM
 * To change this template use File | Settings | File Templates.
 */
import java.util.*;
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            Rule, Reference, RuleDefinition, InternalSchemaErrorException,
//            Schema, Context

class ReferenceRule extends Rule
{

    ReferenceRule(Element element, Schema schema)
    {
        ref = new Reference(element, schema);
    }

    void findApplicableRules(Context context, SortedSet sortedset, Set set)
    {
        if(!set.contains(ref))
        {
            set.add(ref);
            Definition definition = ref.resolve();
            if(!(definition instanceof RuleDefinition))
                throw new InternalSchemaErrorException();
            Rule rule;
            for(Iterator iterator = ((RuleDefinition)definition).contents.iterator(); iterator.hasNext(); rule.findApplicableRules(context, sortedset, set))
                rule = (Rule)iterator.next();

        }
    }

    Reference ref;
}
